﻿package com.singlenotion.display.buttons 
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Adam Jowett (Single Notion)
	 */
	public class TweenButton extends GenericButton
	{
		
		public function TweenButton($on:Boolean = true) 
		{
			super($on);
		}
		
		override protected function onPressListener($e:MouseEvent):void 
		{
			gotoAndPlay("down");
			dispatchEvent(new Event(ButtonEvents.ON_PRESS, false, true));
		}
		
		override protected function onReleaseListener($e:MouseEvent):void 
		{
			dispatchEvent(new Event(ButtonEvents.ON_RELEASE, false, true));
		}
		
		override protected function onRollOverListener($e:MouseEvent):void 
		{
			gotoAndPlay("over");
			dispatchEvent(new Event(ButtonEvents.ON_ROLLOVER, false, true));
		}
		
		override protected function onRollOutListener($e:MouseEvent):void 
		{
			gotoAndPlay("out");
			//(_dimmed) ? gotoAndPlay("out") : gotoAndPlay("up");
			dispatchEvent(new Event(ButtonEvents.ON_ROLLOUT, false, true));
		}
		
		override public function switchOff():void 
		{
			gotoAndPlay("out");
			buttonMode = false;
			removeListeners();
		}
		
		override public function switchOn():void 
		{
			gotoAndPlay("up");
			buttonMode = true;
			mouseChildren = false;
			addListeners();
		}
		
		override public function highlight():void
		{
			gotoAndStop("highlight");
			buttonMode = false;
			removeListeners();
		}
		
		override public function set dimmed($val:Boolean):void
		{
			_dimmed = $val;
			($val) ? gotoAndPlay("out") : gotoAndPlay("up");
		}
	}
	
}